/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2022/2/20
 * Time: 15:33
 * Description:
 */
public class MyDate {

    public int year;
    //year = 100;不能另起一行
    public int month;
    public int day;

    public MyDate() {
        /*this.year = 1998;
        this.month = 1;
        this.day = 1;*/
        this(2008,1,1);//必须在第一行
        System.out.println("不带参数的构造方法！");
    }

    public MyDate(int year,int month,int day) {
        //this();
        this.year = year;
        this.month = month;
        this.day = day;
        System.out.println("带有3个参数的构造方法！");
    }


    public void setDay(int year,int month,int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public void printDay() {
        //this.setDay(1,2,3);
        System.out.println(this.year+"-"+this.month+"-"+this.day);
    }


    public static void main(String[] args) {
        MyDate myDate = new MyDate();

    }


    public static void main2(String[] args) {
        MyDate myDate = new MyDate(2022,2,22);
        myDate.printDay();
    }

    public static void main1(String[] args) {
        MyDate myDate = new MyDate();
        myDate.setDay(2022,2,20);
        myDate.printDay();

        MyDate myDate2 = new MyDate();
        myDate2.setDay(2022,2,22);
        myDate2.printDay();

    }

}
